Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development


Customizing the initializeObject procedure

The next piece of code you need is a localization of the initializeObject procedure. This should first invoke the standard behavior with a RUN SUPER statement, as shown:

 /* Run default behavior first. */ 
    RUN SUPER. 

Next, it retrieves the BrowsePopupActive property value and creates the pop-up menu if the property hasn’t been set to FALSE, as shown:

 {get BrowsePopupActive lPopupActive}. 
    IF lPopupActive THEN 
        RUN createBrowsePopupMenu ( INPUT TARGET-PROCEDURE ). 

.

Note: The code excerpts here are not complete. All variable references, for example, are defined in the procedure or function where they are used. See the accompanying procedure file for the complete code.

Before looking at the createBrowsePopupMenu procedure, the code must identify the key under which the profile values are stored. In order to allow you to customize a browser’s appearance differently in different container windows, the container’s name and the logical browser name are combined to form the key. If the container does not have a LogicalObjectName property value, then it is presumably a static container, so the procedure handle’s FILE-NAME is used instead, as shown:

/* Create the ProfileKey. */ 
    {get ContainerSource hContainerSource}. 
    IF VALID-HANDLE( hContainerSource ) THEN 
        {get LogicalObjectName cContainerName hContainerSource} NO-ERROR. 
    ELSE 
        cContainerName = "". 
     
    IF ( cContainerName = "" ) AND VALID-HANDLE( hContainerSource ) THEN 
        cContainerName = hContainerSource:FILE-NAME. 
    cProfileKey = cContainerName + cBrowserName. 

Using checkProfileDataExists and getProfileData

Now you are ready to access the Profile Manager itself. Use a call to see whether profile data is defined for the profile code and key, as shown:

/* Try to restore column settings. Check the Profile Manager if the profile 
       data we're looking for actually exists... */ 
    RUN checkProfileDataExists IN gshProfileManager ( 
        INPUT "Browser", 
        INPUT "Columns", 
        INPUT cProfileKey, 
        INPUT YES, 
        INPUT NO, 
        OUTPUT lProfileExists ). 

The syntax for the checkProfileDataExists call is:

RUN checkProfileDataExists IN gshProfileManager 
    ( INPUT pcProfileTypeCode, 
      INPUT pcProfileCode, 
      INPUT pcProfileDataKey, 
      INPUT plCheckPermanentOnly, 
      INPUT plCheckCacheOnly, 
      OUTPUT plExists     ). 

These are its parameters:

If there is already profile data for the combination of user, container, and browser, then the next call retrieves it, as shown:

IF lProfileExists THEN 
    DO: 
        ASSIGN rRowID = ?. 
        RUN getProfileData IN gshProfileManager ( 
            INPUT "Browser", 
            INPUT "Columns", 
            INPUT cProfileKey, 
            INPUT NO, 
            INPUT-OUTPUT rRowID, 
            OUTPUT cProfileData ). 

The syntax for the getProfileData call is:

RUN getProfileData IN gshProfileManager 
    ( INPUT pcProfileTypeCode, 
      INPUT pcProfileCode, 
      INPUT pcProfileDataKey, 
      INPUT plNextRecordFlag, 
      INPUT-OUTPUT prRowID, 
      OUTPUT pcProfileData). 

The getProfileData procedure has these parameters:

In its search for your profile data, getProfileData first looks in the client cache if it’s running client side. If the data is not found and this is not a cached profile type, it looks in the database. The procedure always checks for session data first, then permanent data. If a RowID is passed in, then this is used to find the record. The RowID is the RowID of the temp-table if this is a client-only profile type; otherwise it is the RowID of the database record.

Profile types are either maintained completely using the client cache or always read from the database. When trying to get profile data, the procedure first fully caches the entire profile type if it is not already cached and this is a client-only profile type. Normally the full cache is built at application start-up, but profile types can be cached as used.

The initializeObject procedure now has the profile data for this user, container, and browser, if it has been previously saved. If there is data, then the code manipulates the order and size of each browse column accordingly. Because this code is not pertinent to our study of the Profile Manager, just a couple of key lines are reproduced here, as shown:

 
hBrowse:MOVE-COLUMN( iColumnPosition, iLoop ). 
hColumn:WIDTH-PIXELS = INTEGER( ENTRY( 2, cColumnEntry, CHR(4) )).  

Refer to the procedure file for the complete code example.

Next, the code makes similar calls to checkProfileDataExists and getProfileData for data under the Sorting code. If a sort setting comes back, then it resets the query’s sort sequence accordingly, and reopens the SDO’s query. Note that the SDO is the Data-Source for the browser, so following that link identifies the procedure where the query must be reset and reopened. The REFRESHABLE attribute setting keeps the Browse from flashing as it is being manipulated, as shown:

hBrowse:REFRESHABLE = NO. 
DYNAMIC-FUNCTION( "setQuerySort":U IN hDataSource, cProfileData ).  
DYNAMIC-FUNCTION( "openQuery":U IN hDataSource ). 
hBrowse:REFRESHABLE = YES. 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095